package com.qcby.controller;

import com.qcby.annotation.RepeatSubmit;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@RequestMapping("/order")
public class OrderController {

    @GetMapping("/add")
    public String add(){
        return "111";
    }

    @GetMapping("/login")
    public String login(String username, String password) {
        Assert.isTrue("admin".equals(username) && "password".equals(password), "用户名或密码错误");
        return UUID.randomUUID().toString();
    }

    @RepeatSubmit(time = 5000)
    @GetMapping("/createOrder")
    public String createOrder() {
        return "order:" + UUID.randomUUID();
    }
}
